range: remove range_size_request vfunc
authorTimm Bäder <mail@baedert.org>
Fri, 9 Aug 2019 10:08:51 +0000 (12:08 +0200)
committerTimm Bäder <mail@baedert.org>
Fri, 9 Aug 2019 12:30:01 +0000 (14:30 +0200)
It's unneeded in GtkScale and named after the gtk2 size_request function

gtk/gtkrange.c
gtk/gtkrange.h
gtk/gtkscale.c

index 0748a43a4619a163c9feaba8dbe012e8d4d83046..cabb814c4dc98d29a8e649e536afdb79f556157c 100644 (file)
@@ -1381,17 +1381,6 @@ gtk_range_measure (GtkWidget      *widget,
       *minimum += border.top + border.bottom;
       *natural += border.top + border.bottom;
     }
-
-  if (GTK_RANGE_GET_CLASS (range)->get_range_size_request)
-    {
-      gint min, nat;
-
-      GTK_RANGE_GET_CLASS (range)->get_range_size_request (range, orientation,
-                                                           &min, &nat);
-
-      *minimum = MAX (*minimum, min);
-      *natural = MAX (*natural, nat);
-    }
 }
 
 static void
index 13136cadde1ac17d3d324101f73f35b49cc5b392..f62b920c5c8306a6de162b718ccf1956b7a10c12 100644 (file)
@@ -71,11 +71,6 @@ struct _GtkRangeClass
                              GtkScrollType scroll,
                              gdouble       new_value);
 
-   void (* get_range_size_request) (GtkRange       *range,
-                                    GtkOrientation  orientation,
-                                    gint           *minimum,
-                                    gint           *natural);
-
   /*< private > */
 
   gpointer padding[8];
index eaf5056bb39a58590507ff27c698f4f8be3fa09b..ba5b2d21300fe0a1d90624302164bf64dc999730 100644 (file)
@@ -197,10 +197,6 @@ static void     gtk_scale_measure (GtkWidget      *widget,
                                    int            *natural_baseline);
 static void     gtk_scale_get_range_border        (GtkRange       *range,
                                                    GtkBorder      *border);
-static void     gtk_scale_get_range_size_request  (GtkRange       *range,
-                                                   GtkOrientation  orientation,
-                                                   gint           *minimum,
-                                                   gint           *natural);
 static void     gtk_scale_finalize                (GObject        *object);
 static void     gtk_scale_snapshot                (GtkWidget      *widget,
                                                    GtkSnapshot    *snapshot);
@@ -665,7 +661,6 @@ gtk_scale_class_init (GtkScaleClass *class)
   widget_class->measure = gtk_scale_measure;
 
   range_class->get_range_border = gtk_scale_get_range_border;
-  range_class->get_range_size_request = gtk_scale_get_range_size_request;
   range_class->value_changed = gtk_scale_value_changed;
 
   class->get_layout_offsets = gtk_scale_real_get_layout_offsets;
@@ -1220,12 +1215,12 @@ gtk_scale_get_has_origin (GtkScale *scale)
  * gtk_scale_set_value_pos:
  * @scale: a #GtkScale
  * @pos: the position in which the current value is displayed
- * 
+ *
  * Sets the position in which the current value is displayed.
  */
 void
 gtk_scale_set_value_pos (GtkScale        *scale,
-                        GtkPositionType  pos)
+                         GtkPositionType  pos)
 {
   GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
   GtkWidget *widget;
@@ -1238,9 +1233,7 @@ gtk_scale_set_value_pos (GtkScale        *scale,
       widget = GTK_WIDGET (scale);
 
       update_value_position (scale);
-
-      if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget))
-       gtk_widget_queue_resize (widget);
+      gtk_widget_queue_resize (widget);
 
       g_object_notify_by_pspec (G_OBJECT (scale), properties[PROP_VALUE_POS]);
     }
@@ -1361,27 +1354,6 @@ gtk_scale_get_range_border (GtkRange  *range,
     }
 }
 
-static void
-gtk_scale_get_range_size_request (GtkRange       *range,
-                                  GtkOrientation  orientation,
-                                  gint           *minimum,
-                                  gint           *natural)
-{
-  GtkScalePrivate *priv = gtk_scale_get_instance_private (GTK_SCALE (range));
-
-  /* Ensure the range requests enough size for our value */
-  if (priv->value_widget)
-    gtk_widget_measure (priv->value_widget,
-                        orientation, -1,
-                        minimum, natural,
-                        NULL, NULL);
-  else
-    {
-      *minimum = 0;
-      *natural = 0;
-    }
-}
-
 static void
 gtk_scale_measure_mark (GtkGizmo       *gizmo,
                         GtkOrientation  orientation,
@@ -1466,6 +1438,7 @@ gtk_scale_measure (GtkWidget      *widget,
 {
   GtkScale *scale = GTK_SCALE (widget);
   GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
+  GtkOrientation scale_orientation;
 
   GTK_WIDGET_CLASS (gtk_scale_parent_class)->measure (widget,
                                                       orientation,
@@ -1473,7 +1446,9 @@ gtk_scale_measure (GtkWidget      *widget,
                                                       minimum, natural,
                                                       minimum_baseline, natural_baseline);
 
-  if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == orientation)
+  scale_orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
+
+  if (scale_orientation == orientation)
     {
       int top_marks_size = 0, bottom_marks_size = 0, marks_size;
 
@@ -1493,6 +1468,41 @@ gtk_scale_measure (GtkWidget      *widget,
       *minimum = MAX (*minimum, marks_size);
       *natural = MAX (*natural, marks_size);
     }
+
+  if (priv->value_widget)
+    {
+      int min, nat;
+
+      gtk_widget_measure (priv->value_widget, orientation, -1, &min, &nat, NULL, NULL);
+
+      if (priv->value_pos == GTK_POS_TOP ||
+          priv->value_pos == GTK_POS_BOTTOM)
+        {
+          if (orientation == GTK_ORIENTATION_HORIZONTAL)
+            {
+              *minimum = MAX (*minimum, min);
+              *natural = MAX (*natural, nat);
+            }
+          else
+            {
+              *minimum += min;
+              *natural += nat;
+            }
+        }
+      else
+        {
+          if (orientation == GTK_ORIENTATION_HORIZONTAL)
+            {
+              *minimum += min;
+              *natural += nat;
+            }
+          else
+            {
+              *minimum = MAX (*minimum, min);
+              *natural = MAX (*natural, nat);
+            }
+        }
+    }
 }
 
 static void